
from _spice_path import spice_path

def _tolerance(spiceref,motorname):
    motorglobal=spiceref.GetVIReference(spice_path + '\\common\\globals\\motor_globals.vi')
    searchvi=spiceref.GetVIReference(spice_path + '\\common\\Utilities\\device_utilities\\SearchMotorListByNameOrAlias.vi')
    parnames='Motor','Device Index','Motor Index','found?'
    parvalues=motorname,0,0,0
    searchnames,searchvalues=searchvi.Call(parnames,parvalues)
    motorindexvalue=searchvalues[2]
    tolvalues=motorglobal.GetControlValue('Motor Tolerance')
    tolerance=tolvalues[motorindexvalue]
    return tolerance
